package com.test.config;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.test.controller.ArticleController;
import com.test.controller.HomeController;
import com.test.controller.PointController;
import com.test.controller.ReplyController;
import com.test.controller.SignController;
import com.test.controller.UserController;
import com.test.model.Article;
import com.test.model.Point;
import com.test.model.Reply;
import com.test.model.Sign;
import com.test.model.User;

/**
 * <p>description: 核心配置</p>
 * <p>Date: 2014年12月22日 上午10:21:09</p>
 * <p>modify：</p>
 * @author: guanyuhui
 * @version: 2.0
 */
public class CoreConfig extends JFinalConfig{

	@Override
	public void configConstant(Constants constant) {
		constant.setViewType(ViewType.JSP);
		constant.setDevMode(true);
		constant.setEncoding("utf-8");
	}

	@Override
	public void configHandler(Handlers handler) {
		
	}

	@Override
	public void configInterceptor(Interceptors interceptor) {
		
	}

	@Override
	public void configPlugin(Plugins plugin) {
		C3p0Plugin cp = new C3p0Plugin("jdbc:mysql://10.4.26.93:3306/db405bedea45c47a39ff0c47241a3baee?characterEncoding=utf8","uQI8d7MdFx9kq","pgBXLmDaqEJ8R");
		plugin.add(cp);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(cp);
		plugin.add(arp);
		arp.addMapping("user", User.class);
		arp.addMapping("article", Article.class);
		arp.addMapping("reply", Reply.class);
		arp.addMapping("point", Point.class);
		arp.addMapping("sign", Sign.class);
	}

	@Override
	public void configRoute(Routes route) {
		route.add("/", HomeController.class);
		route.add("/article", ArticleController.class);
		route.add("/reply", ReplyController.class);
		route.add("/user", UserController.class);
		route.add("/point", PointController.class);
		route.add("/sign", SignController.class);
	}

}